import Vue from "vue";
import VueRouter from "vue-router";
// 默认导入目录下的 index.vue 文件，等价于 ./views/login/index.vue
import Login from './views/login'
import Layout from '@/components/layout.vue'
import Home from './views/home'
import Member from './views/member'
import Supplier from './views/supplier'
import Goods from './views/goods'
import Staff from './views/staff'

Vue.use(VueRouter);

const routes = [
  {
    // 登录页
    path: '/login',
    name: 'login', //路由名称
    component: Login
  },
  {
    // 布局
    path: '/',
    name: 'layout', //路由名称
    component: Layout,
    redirect: '/home', //重定向
    children: [
      {
        path: '/home',
        component: Home,
        meta: { title: '首页' }
      },
      // {
      //   path: '/member',
      //   component: Member
      // }
    ]
  },
  // 请求 ‘/member’ 路由 到 Layout 布局组件，再请求 ‘/’ 把子组件 Member 路由到 布局组件中的路由出口
  {
    path: '/member',
    component: Layout,
    children: [
      {
        path: '/', // /member/
        component: Member,
        meta: { title: '会员管理' }
      }
    ]
  },
  {
    path: '/supplier',
    component: Layout,
    children: [
      {
        path: '/',
        component: Supplier,
        meta: { title: '供应商管理' }
      }
    ]
  },
  {
    path: '/goods',
    component: Layout,
    children: [
      {
        path: '/',
        component: Goods,
        meta: { title: '商品管理' }
      }
    ]
  },
  {
    path: '/staff',
    component: Layout,
    children: [
      {
        path: '/',
        component: Staff,
        meta: { title: '员工管理' }
      }
    ]
  }
];

const router = new VueRouter({
  routes
});

export default router;
